<!--
 * @Author: XN
 * @Date: 2020-11-28 18:53:57
 * @LastEditTime: 2020-12-03 19:04:11
 * @LastEditors: XN
 * @Description:
 * @FilePath: /lab-car/html/login.html
-->
<!DOCTYPE html>
<html lang="en">

    <head>
        <meta charset="UTF-8">
        <meta name="viewport" content="width=device-width, initial-scale=1.0">
        <meta http-equiv="X-UA-Compatible" content="ie=edge">
        <link rel="stylesheet" href="/css/bootstrap.min.css">
        <link rel="stylesheet" href="/css/nav.css">
        <link rel="stylesheet" href="/css/login.css">
        <script src="../js/jquery-3.4.1.min.js"></script>
        <script src="/js/bootstrap.min.js"></script>
        <script src="/js/hullabaloo.min.js"></script>
        <title>车联网信息分发</title>
    </head>

    <body>
        <div class="my-login-box">
            <h2>登录</h2>
            <form>
                <div class="user-box" id="userNameForm">
                    <input type="text" id="userNameLogin" name="" required="">
                    <label>用户名</label>
                </div>
                <div class="user-box">
                    <input type="password" id="passWordLogin" name="" required="">
                    <label>密码</label>
                </div>
                <!-- <button onclick="submitLogin()" class="button button--rayen button--border-thin button--text-thick button--text-upper button--size-s" data-text="提交"><span>提交</span></button> -->
                <a type="button" href="javascript:void(0);" onclick="submitLogin()">
                    <span></span>
                    <span></span>
                    <span></span>
                    <span></span>
                    提交
                </a>
            </form>
        </div>

    </body>
    <script type="text/javascript">
        $(document).ready(function () {
            var hulla = new hullabaloo()
            submitLogin = () => {
                var userName = document.getElementById("userNameLogin").value;
                var password = document.getElementById("passWordLogin").value;
                if (userName == '') {
                    hulla.send('用户名不为空', 'danger')
                }
                if (password == '') {
                    hulla.send("密码不为空", 'danger')
                }
                if (userName != '' && password != '') {
                    // userName = parseInt(userName);
                    $.ajax({
                        url: '../../ucenter/login', //引入地址
                        type: 'POST', //请求方式
                        data: {
                            phoneOrEmail: userName,
                            password: password
                        },
                        success: function (response) {
                            $('.help-block').remove()
                            if (response.success) {
                                hulla.send(response.msg, 'success')
                                window.location.href = "infoCenter.html"
                            }
                        },
                        error: function (response) {
                            hulla.send(response.msg, 'danger')
                        }
                    })
                }
            }
        });
    </script>
</html>
